/**
 * 
 */
package org.lanqiao.netctoss.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.lanqiao.netctoss.dao.BussDao;
import org.lanqiao.netctoss.entity.Acount;
import org.lanqiao.netctoss.entity.Buss;
import org.lanqiao.netctoss.entity.CheckBill;
import org.lanqiao.netctoss.entity.Tariff;
import org.lanqiao.netctoss.service.BussService;
import org.lanqiao.netctoss.util.GetSession;

/**
 * @author Administrator
 *
 */
public class BussServiceImpl implements BussService {

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#insertBuss(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public int insertBuss(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		int b = session.getMapper(BussDao.class).insertBuss(buss);
		if(b>0){
			session.commit();
			session.close();
		}
		return b;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#deleteBuss(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public int deleteBuss(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		int b = session.getMapper(BussDao.class).deleteBuss(buss);
		if(b>0){
			session.commit();
			session.close();
		}
		return b;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#updateBussState(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public int updateBussState(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		int b = session.getMapper(BussDao.class).updateBussState(buss);
		if(b>0){
			session.commit();
			session.close();
		}
		return b;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#updateBussByno(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public int updateBussByno(Buss buss) {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#selectBussByCondition(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public List<Buss> selectBussByCondition(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		BussDao bussDao = session.getMapper(BussDao.class);
		List<Buss> lb = bussDao.selectBussByCondition(buss);
		if(lb!=null){
			session.commit();
			session.close();
		}
		return lb;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#selectBuss()
	 */
	@Override
	public List<Buss> selectBuss() {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		List<Buss> lb = session.getMapper(BussDao.class).selectBuss();
		if(lb!=null){
			session.commit();
			session.close();
		}
		return lb;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#selectBusstByno(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public List<Buss> selectBusstByno(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		List<Buss> lb = session.getMapper(BussDao.class).selectBusstByno(buss);
		if(lb!=null){
			session.commit();
			session.close();
		}
		return lb;
	}

	/* (non-Javadoc)
	 * @see org.lanqiao.netctoss.service.BussService#selectTarBybno(org.lanqiao.netctoss.entity.Buss)
	 */
	@Override
	public List<Tariff> selectTarBybno(Buss buss) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		List<Tariff> lt = session.getMapper(BussDao.class).selectTarBybno(buss);
		if(lt!=null){
			session.commit();
			session.close();
		}
		return lt;
	}

	@Override
	public List<Buss> selectBussByAco_user(CheckBill checkBill) {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		List<Buss> lb = session.getMapper(BussDao.class).selectBussByAco_user(checkBill);
		if(lb!=null){
			session.commit();
			session.close();
		}
		return lb;
	}

}
